var config = require('./webpack.config.base');
var path = require('path');
var rootPath = path.join(__dirname, './');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var webpack = require('webpack');
config.mode = 'development';
config.devtool = 'source-map';
config.output.filename = '[name].js';
config.output.chunkFilename = '[id].js';
config.output.publicPath = '/';
config.plugins.push(
  new HtmlWebpackPlugin({
    filename: '../index.html',
    template: 'src/index.html',
    chunkSortMode: 'none',
    minify: {
      collapseWhitespace: true, //移除空行
      removeComments: true, //移除注释
      minifyJS: true, // 压缩html里的js（使用uglify-js进行的压缩）
      minifyCSS: true, // 压缩html里的css（使用clean-css进行的压缩）
    },
  }),

  new CopyWebpackPlugin([
    // 复制高度静态资源
    {
      from: path.join(rootPath, 'static'),
    },
  ]),
  new webpack.LoaderOptionsPlugin({
    debug: true,
  }),
  new MiniCssExtractPlugin({
    //对单独生成的css重命名
    filename: '[name].css',
  })
);
module.exports = config;
